home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / str_check.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-02  |  857 b   |  46 lines

  1. /*
  2.    str_check: check a string value and make sure it is in the list of
  3.    acceptable values.
  4.  
  5.    Kenneth Ingham
  6.  
  7.    Copyright (C) 1988 The University of New Mexico
  8. */
  9.  
  10. #include "defs.h"
  11.  
  12. str_check(value, acceptable, cmd, name, line)
  13. char *value, **acceptable;
  14. char *cmd, *name, *line;
  15. {
  16.     extern int line_ok;
  17.     int ok, i;
  18.  
  19.     ok = False;
  20.  
  21.     for (i=0; acceptable[i]; i++) {
  22.         if (strcmp(acceptable[i], value) == 0) {
  23.             ok = True;
  24.             break;
  25.         }
  26.     }
  27.  
  28.     if (!ok) {
  29.         if (line_ok) {
  30.             printf("%s has a string ", cmd);
  31.             printf("value which is not valid:\n");
  32.             printf("%s\n",line);
  33.         }
  34.         else {
  35.             printf("Also, it has a string ");
  36.             printf("value which is not valid:\n");
  37.         }
  38.         printf("where %s = '%s'; Should be '%s'", name, value,
  39.             acceptable[0]);
  40.         for (i=1; acceptable[i]; i++)
  41.             printf(" or '%s'",acceptable[i]);
  42.         printf("\n");
  43.         line_ok = False;
  44.     }
  45. }
  46.